/*
 * ModeloTabla.java
 *
 * Created on 18-dic-2007, 15:57:11
 *
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package jschoolmanagerportable.gui.model;

import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Administrador
 */
public class ModeloTabla extends AbstractTableModel {

    private String[] columnNames = {"Nombre", "N1", "N2", "N3", "N4", "N5", "N6", "N7", "N8", "N9", "N10", "Prom"};
    private Object[][] data;

    public ModeloTabla(){
        int cantNotas=10+1;
        String[] nombres = {"Jc","Bill","Josh","Jhonatan","Rodrigo","James","Jc","Bill","Josh","Jhonatan","Rodrigo","James","Jc","Bill","Josh","Jhonatan","Rodrigo","James"};
        data = new Object[nombres.length][cantNotas+1];
      
        int paso=0;
        for(String n:nombres){
            data[paso][0] = n;
            for(int x=1;x<cantNotas+1;x++){
                data[paso][x] = (double) (x>7?6:x);
            }
            paso++;
        }
    }
    
    public int getColumnCount() {
        return columnNames.length;
    }

    public int getRowCount() {
        return data.length;
    }

    public String getColumnName(int col) {
        return columnNames[col];
    }

    public Object getValueAt(int row, int col) {
        return data[row][col];
    }

    public Class getColumnClass(int c) {
        return getValueAt(0, c).getClass();
    }

    /*
     * Don't need to implement this method unless your table's
     * editable.
     */
    public boolean isCellEditable(int row, int col) {
        //Note that the data/cell address is constant,
        //no matter where the cell appears onscreen.
        if (col == 0 || col==(this.getColumnCount()-1)) {
            return false;
        } else {
            return true;
        }
    }

    /*
     * Don't need to implement this method unless your table's
     * data can change.
     */
    public void setValueAt(Object value, int row, int col) {
        data[row][col] = value;
        fireTableCellUpdated(row, col);
    }
}